<%-- 
    Document   : viewUser
    Created on : Apr 30, 2011, 8:49:02 PM
    Author     : christophe
--%>

<%@page import="java.util.List"%>
<%@page import="com.garagesale.data.User"%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@include file="/WEB-INF/jspf/tagImports.jspf" %>

<!-- The following page directive is needed for c:out to work properly.. otherwise,  -->
<!-- you get the following error: "According to TLD or attribute directive in tag file, attribute var does not accept any..." -->


<html:html lang="true">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>List Items</title>
    </head>
    <tags:menu />
    <div id ="content">
        <tags:body>

            <c:url var="listItemsUrl" value="/user/listItems.do" />

            <form action="${listItemsUrl}" method="post">


                <h2>Items for Sale</h2>

                <div class="filters" id="filters">
                    <tags:textInput formFieldName="nameFilter" labelName="Item Name" textValue="${ListItemsForm.nameFilter}" />
                    <tags:textInput formFieldName="descriptionFilter" labelName="Item Description" textValue="${ListItemsForm.descriptionFilter}" />
                    <tags:textInput formFieldName="lowerPriceFilter" labelName="Priced at no less than" textValue="${ListItemsForm.lowerPriceFilter}" />
                    <tags:textInput formFieldName="upperPriceFilter" labelName="Priced at no more than" textValue="${ListItemsForm.upperPriceFilter}" />

                    <div class="input">
                        <label for="name">Item Categories</label>

                        <html:select name="ListItemsForm" property="categoryFilter">
                            <option value="">None</option>
                            <c:forEach var="category" items="${ListItemsForm.categories}">
                                <html:option value="${category.itemCategoryID}" >
                                    <c:out value="${category.name}" />
                                </html:option>
                            </c:forEach>
                        </html:select>

                    </div>

                    <input type="submit" value="Find Stuff to Buy" />
                </div>

                <table style="border-style: solid;">
                    <tr style="border-style: inherit;">
                        <th>Name</th>
                        <th>Description</th>
                        <th>Price</th>
                        <th>Category</th>
                        <th>View</th>
                    </tr>
                    <c:forEach var="item" items="${ListItemsForm.items}" >
                        <tr>
                            <c:url var="viewItemUrl" value="/user/viewItem.do">
                                <c:param name="itemID" value="${item.itemID}" />
                            </c:url>
                            <td><c:out value="${item.name}" /></td>
                            <td><c:out value="${item.description}" /></td>
                            <td><c:out value="${item.salePrice}" /></td>
                            <td style="background-color: ${item.itemCategory.labelColor};"><c:out value="${item.itemCategory.name}" /></td>
                            <td><a href="${viewItemUrl}">View Item </a> </td>
                        </tr>
                    </c:forEach>
                </table>

            </form>
        </div>
    </tags:body>
    <div id = "footer">
        <span>
            &nbsp;All rights reserved Garage Sale 2011 | Legal | Privacy Policy
        </span>
        <br><br>
        <img alt="" src="../../images/b1.gif">
        <img alt="" src="../../images/b2.gif" style="margin:0px 5px 0px 5px">
        <img alt="" src="../../images/b3.gif">
    </div>
</html:html>
